package cn.sunzq.springdata.elasticsearch.demo.config;

import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.client.ClientConfiguration;
import org.springframework.data.elasticsearch.client.RestClients;
import org.springframework.data.elasticsearch.config.AbstractElasticsearchConfiguration;

/**
 * @创建人 孙中泉
 * @创建时间 2021/7/19
 * @描述 没密码配置
 */
//@Configuration
public class RestClientConfig extends AbstractElasticsearchConfiguration {

    @Value("${es.hosts:localhost:9200}")
    private String hostAndPort;

    @Override
    public RestHighLevelClient elasticsearchClient() {
        return RestClients.create(ClientConfiguration.create(hostAndPort)).rest();
    }
}
